package main

import (
	"fmt"
	"reflect"
	"strings"
)

//CusType CusType
type CardListConf_Default struct {
	CardDetail_Default [][]string
}

//User User
type User struct {
	ID                   int    `json:"id"`
	Name                 string `json:"name"`
	addr                 string
	CardListConf_Default CardListConf_Default
	Xstrata              map[string]CardListConf_Default
}

func main() {
	bk := false
	var cardDetail [][]string
	u := User{ID: 1001, Name: "aaa", addr: "bbb"}
	ti := reflect.TypeOf(u)
	vi := reflect.ValueOf(u)
	fmt.Printf("%s\n\r", vi.FieldByName("Xstrata").Type())
	xxx, ok := reflect.New(vi.FieldByName("Xstrata").Type()).Interface().(map[string]interface{})
	if ok {
		vi.FieldByName("Xstrata").Set(reflect.ValueOf(xxx))
	}
	for i := 0; i < vi.NumField(); i++ {
		if vi.Field(i).CanInterface() {
			if strings.HasPrefix(ti.Field(i).Name, "CardListConf_") {
				tj := reflect.TypeOf(vi.Field(i).Interface())
				vj := reflect.ValueOf(vi.Field(i).Interface())
				for j := 0; j < vj.NumField(); j++ {
					fmt.Printf("tj.Field(j).Name: %s\n\r", tj.Field(j).Name)
					if vj.Field(j).CanInterface() {
						vt, ok := vj.Field(j).Interface().([][]string)
						if ok {
							bk = true
							cardDetail = vt
							break
						}
					}
				}
			}
			if bk {
				break
			}
		}
	}
	for _, v := range cardDetail {
		fmt.Printf("%s\n\r", v)
	}
}
